from selenium import webdriver
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

from selenium.webdriver.remote.webelement import WebElement

options = webdriver.ChromeOptions()
options.add_argument("--headless")
options.add_argument("--disable-gpu")
driver = webdriver.Chrome(executable_path="c:/Users/hj137/Desktop/chromedriver",
                          options=options)
driver.get(
    "https://sou.zhaopin.com/?p=5&jl=801&sf=0&st=0&kw=Python&kt=3")
try:
    # 等待期望的条件发生
    WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.CLASS_NAME, "contentpile__content")))
except Exception as e:
    print(e)

time.sleep(2)
tag = driver.find_element_by_class_name("contentpile__content")
while True:
    # 迭代tag
    for t in tag.find_elements_by_class_name("itemBox"):
        title = t.find_element_by_tag_name("span")
        s = title.find_elements_by_class_name('JobName')
        # titles = s.text
        # titlel = titles.split(' ')
        # username = user_info[0].text
        # age = user_info[1].text
        # gender = user_info[2].text
        print(s)


    driver.quit()
